<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8"/>
    <title>学期信息-编辑信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <script src="layui-v2.5.4/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.5.4/css/layui.css">
</head>
<body>

<div class="layui-row" >

    <form id="editForm" class="layui-form layui-form-pane" action="/saveCc.do" style="margin: 20px;align:center;">
        <input type="hidden" name="id" value="" class="layui-input">
        <div class="layui-form-item">
            <label class="layui-form-label" ><i style="color:red;">*</i> 学期名称</label>
            <div class="layui-input-block" >  
                <input type="text" name="semesterName" id="semesterName" lay-verify="required" maxlength="50" placeholder="请输入学期名称" value="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" ><i style="color:red;">*</i>学期编码</label>
            <div class="layui-input-block" >
                <input type="text" name="code" id="code" lay-verify="" maxlength="200" placeholder="请输入学期编码" value="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" ><i style="color:red;">*</i> 排序</label>
            <div class="layui-input-block">
                <input type="text" name="dataSort" id="dataSort" lay-verify="required" maxlength="3" placeholder="请输入排序数字，从小到大排序" value="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" >
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="editSub">提交</button>
                <button type="button" class="layui-btn layui-btn-primary" >取消</button>
            </div>
        </div>
    </form>

</div>

<script>
    layui.use(['form','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(editSub)', function(data){
            console.log(data);
            $.post('/management/semester/saveSemester.do', data.field, function (res) {
                if (res == 200) {
                    layer.msg('编辑成功', { icon: 1, time: 800, shade: 0.3 }, function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.layui.table.reload('userList');
                    });
                }else if(res == 300){
                    layer.msg('编辑失败', { icon: 2, time: 800, shade: 0.3},function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }
            });
            return false;
        });
    });
</script>

</body>
</html>